<extend name="Public:template" />
<block name="page_header">
	<ul class="header-sub">
		<li class="previous"><a href="{:U('Index/index')}" role="button" class="btn btn-default active" role="button"><span class="icon icon-home"></span>首页</a></li>
		<li ><h3>完善个人信息</h3></li>
		<li class="next "><a href="{:U('Cust/index')}" class="btn btn-warning active" role="button">我的<span class="icon-white icon-user"></span></a></li>
	</ul>
</block>
<block name="page_body">
<div id="alert_box">
	<div class="alert-sm alert-success" style="display:none"></div>
	<div class="alert-sm alert-danger" style="display:none"></div>
</div>
<form action="{:U('CustPassport/doUpd')}" method="post" id="form_edit" name="form_edit" role="form">
	<input type="hidden" name="sex" value="{$cust.sex}">
	<div class="input-group mt5">
		<span class="input-group-addon alert-warning">姓名或昵称</span>
		<input type="text" class="form-control"  id="name" name="name" value="{$cust.name}" placeholder="请输入姓名或昵称">
	</div>
	<div class="input-group  mt15">
		  <span class="input-group-addon" id="man" onclick="updSex('先生')" >先生</span>
		  <span class="input-group-addon" id="woman" onclick="updSex('女士')">女士</span>
	</div>
	<button type="button" id="doUpdBtn" class="btn btn-warning btn-lg btn-block active mt15">提交修改</button>
</form>
</block>
<block name="script_footer">
<script type="text/javascript">
$(document).ready(function(){
	updSex('{$cust.sex}');		
	$("#doUpdBtn").on( "click", function() {
		$("#alert_box .alert-danger").hide();
		$("#alert_box .alert-success").hide();
		$.ajax({
	        'url': $("#form_edit").attr("action"),
	        'type':"post",
	        'dataType': "json",
	        'data': $('#form_edit').serialize(),
	        'success': function (data) {
	        	var error = data['error'];
	        	var message = data['message'];
	        	if(error=='0'){
	        		$("#alert_box .alert-success").html(message).show;
	        		alert(message);
	        		document.location.href="/Cust/index.html"; 
	        	}else{
	        		$("#alert_box .alert-danger").html(message).show();
	        	}
	        }
	    });
	});
})
function updSex(sex){
	if('女士' == sex){
		$("#man").removeClass("btn-primary active").addClass("btn-default");
		$("#woman").removeClass("btn-default").addClass("btn-danger active");
		document.forms['form_edit'].sex.value="女士";
	}else{
		$("#man").removeClass("btn-default").addClass("btn-primary active");
		$("#woman").removeClass("btn-danger active").addClass("btn-default");
		document.forms['form_edit'].sex.value="先生";
	}
}
function changeShop(){
	// $("#ddlRegType").find("option:selected").text();
	var shop_id = $("#shop_id").val();
	if(shop_id!=''){
		$("#alert_box .alert-success").html("配送范围："+$("#deliver"+shop_id).attr("deliver_around"));
		$("#alert_box .alert-success").show();
	}else{
		$("#alert_box .alert-success").html("如果配送地址没有覆盖您的区域，请联系我们的客服");
		$("#alert_box .alert-success").show();
	}

}
</script>
</block>